#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMenu>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QMenuBar* menubar  = new QMenuBar(this);
    setMenuBar(menubar);

    QMenu* menu1 = new QMenu("文件(&F)");
    QMenu* menu2 = new QMenu("编辑");
    QMenu* menu3 = new QMenu("保存");
    menubar->addMenu(menu1);
    menubar->addMenu(menu2);
    menubar->addMenu(menu3);

    QAction* a = new QAction("新建");
    QAction* b = new QAction("打开");
    QAction* c = new QAction("保存");
    QAction* d = new QAction("另存为");

    menu1->addAction(a);
    menu1->addAction(b);
    menu1->addAction(c);
    menu1->addAction(d);

    connect(a, &QAction::triggered, this, [](){qDebug()<<"新建";});
    connect(b,&QAction::triggered, this, &QMainWindow::close);
}

MainWindow::~MainWindow()
{
    delete ui;
}

